package platform.user.auth.token;

import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.userdetails.UserDetails;

/**
 * @author roamer
 * @version V1.0
 * @date 2019-03-10 15:49
 */
public class TokenAuthenticationToken extends AbstractAuthenticationToken {
    private static final long serialVersionUID = 1L;

    private UserDetails userDetails;

    private SessionToken token;

    public TokenAuthenticationToken(
            UserDetails userDetails, SessionToken token, UserDetails managerDetails) {
        super(userDetails.getAuthorities());
        this.userDetails = userDetails;
        this.token = token;
        this.setDetails(managerDetails);
    }

    @Override
    public Object getCredentials() {
        return token.getValue();
    }

    @Override
    public Object getPrincipal() {
        return userDetails;
    }

    public SessionToken getToken() {
        return token;
    }
}
